<?php 
if(isset($_POST['action']) && $action=='Add To Cart')
{
$cart=$HTTP_COOKIE_VARS["Cart"];
$cart=$cart.'##,'.$_SESSION['SITE_ID'].','.$pid.','.$name.','.$qty.','.$price.','.$cur_dt.','.$Tprice.','.$discount.','.$addon_inc.','.$Fprice;
setcookie("Cart",$cart,time()+604800);
?>
<script type="text/javascript">
alert('Item Added to Cart!!');
window.close('cart_details.php');
</script>
<?php
}
?>
<style type="text/css">
<!--
.style12 {font-family: Verdana; font-size: 10px; font-weight: bold; }
body,td,th {
	color: #FFFFFF;
}
body {
	background-color: #000000;
}
.style13 {font-family: Verdana; font-size: 14px; font-weight: bold; }
.style15 {font-size: 12px}
-->
</style>
<?php
include_once('ClsSebent/config.php');
/*if($action=='Add To Cart')
{//echo $action;
$cur_dt=date("m/d/Y");
$adqry="insert into cart_temp(`site_id` , `prod_code` , `name` , `qty` , `unit_pr` , `cur_dt` , `Tprice` , `discount` , `addon_inc` , `Total`) values($_SESSION['SITE_ID'], $pid, '$name', $qty, $price, '$cur_dt', $Tprice, $discount, $addon_inc, $Fprice)";
mysql_query($adqry);
//echo $adqry;
//echo"<h4><font color=\"red\" face=\"verdana\">Added to cart</h4>";?>
<script type="text/javascript">
alert('Item Added to Cart!!');
window.close('cart_details.php');
</script>
<?php
}*/
$dq="select *from product_master where id=".$pid;
//echo $dq;
$rq=mysql_query($dq);
$rw=mysql_fetch_array($rq);
//$qr="select * from cart_subprod where sprod_code=".$sp;
$qr="select * from site_product where product_id=".$pid." and site_id=".$_SESSION['SITE_ID'];
//echo $qr;
$rs=mysql_query($qr);
$row=mysql_fetch_array($rs);
?>
<form name="formx" method="post" action="cart_details.php">
<input name="pid" value="<?php echo $pid;?>" type="hidden">
<input name="site_id" value="<?php echo $_SESSION['SITE_ID'];?>" type="hidden">
  <table width="400" border="0" align="center">
    <tr>
      <td colspan="3"><div align="center" class="style13">Price Calculations</div></td>
    </tr>
    <tr>
      <td width="91"><span class="style12">Item Code </span></td>
      <td width="192"><strong>&nbsp;<?php echo $row["id"];?></strong></td>
      <td width="103" rowspan="5" valign="top"><span class="style12"><span class="style15">You must add the item to cart if you want to buy. You can use Calculate multiple times for cost calculation. </span></span></td>
    </tr>
    <tr>
      <td><span class="style12">Name</span></td>
      <td><strong>&nbsp;<?php echo $row["product_title"];?><input name="name" type="hidden" value="<?php echo $row["product_title"];?>"></strong></td>
    </tr>
    <tr>
      <td><span class="style12">Price(Inc. Tax)</span></td>
      <td><strong>$<?php echo $row["final_price"];?><input name="price" type="hidden" value="<?php echo $row["price"];?>"></span></strong></td>
    </tr><!--
    <tr>
      <td><span class="style12">Size</span></td>
      <td><strong>&nbsp;<?php echo $row["size"];?><input name="size" value="<?php echo $size;?>" type="hidden"></strong></td>
      <td><input name="action2" type="button" value="View Cart" onclick="javascript: window.open('cart_view.php?site_id=<?php echo $_SESSION['SITE_ID'];?>');" /></td>
    </tr>-->
    <tr>
      <td class="style12"><span class="style12">Lot Size</span></td>
      <td class="style12">&nbsp;<?php echo $rw["lot_size"];?></td>
    </tr>
    <tr>
      <td class="style12"><span class="style12">Lot Discount</span></td>
      <td class="style12">&nbsp;<?php echo $rw["lot_discount"];?></td>
    </tr>
    <tr>
      <td class="style12"><span class="style12">Max  Discount</span></td>
      <td class="style12">$<?php echo $rw["max_discount"];?></td>
      <td class="style12">&nbsp;</td>
    </tr>
    <tr>
      <td><span class="style12">With Addon</span></td>
      <td><select name="addon">
	  <option selected="--None--" value="0">--None--</option>
	  <?php //Listing Addons.
  $adq="select * from product_addon p inner join site_addon s on p.addon_id =s.addon_id where s.site_id=$_SESSION['SITE_ID'] and s.product_id=$pid and Active='Y'";
  $ar=mysql_query($adq);
  while($adrow=mysql_fetch_array($ar))
  {
  ?>
  <option value="<?php echo $adrow['addon_id'];?>"><?php echo $adrow['addon_title'];?></option>
  <?php }?>
      </select>      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><span class="style12">Quantity</span></td>
      <td><span class="style12">
        <input type="text" name="qty" value="<?php echo $qty;?>">
        Units </span></td>
      <td><input name="action2" type="button" value="Calculate" onclick="javascript: window.open('cart_calculate.php?site_id=<?php echo $_SESSION['SITE_ID'];?>&amp;pid=<?php echo $pid;?>&amp;addon='+ document.formx.addon[document.formx.addon.selectedIndex].value+'&amp;qty='+window.document.formx.qty.value,'','width=0, height=0'); window.focus();" /></td>
    </tr>
    <tr>
      <td><span class="style12">Total Price </span></td>
      <td><input name="Tprice" type="text" value="<?php echo $Tprice;?>"></td>
      <td><input name="action" type="submit" value="Add To Cart" /></td>
    </tr>
    <tr>
      <td><span class="style12">Discount</span></td>
      <td><input name="discount" type="text" value="<?php echo $discount;?>"></td>
      <td><input name="action" type="button" value="More Items" onclick="javascript: window.close('cart_details.php');" /></td>
    </tr>
    <tr>
      <td><span class="style12">Addon Increase </span></td>
      <td><input name="addon_inc" type="text" value="<?php echo $addon_inc;?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><span class="style12">Final Price </span></td>
      <td><input name="Fprice" type="text" value="<?php echo $Fprice;?>"></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
 </form>
